package com.motu.monstercity.server.game.logic;

import com.motu.monstercity.server.game.commondata.union.*;
import com.motu.vertx.module.utility.mysql.MysqlClient;
import com.motu.vertx.module.utility.mysql.MysqlTool;
import com.motu.vertx.module.utility.toolset.Tool;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.json.JsonArray;
import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

public class UnionBaseData {
    private static Logger logger = LoggerFactory.getLogger(UnionBaseData.class);


    private static ConcurrentHashMap<Integer, UnionDecorate> unionDecorateMap = new ConcurrentHashMap<>(); // 联盟旗帜头像装扮表
    private static ConcurrentHashMap<Integer, UnionTag> unionTagMap = new ConcurrentHashMap<>(); // 联盟标签表
    private static ConcurrentHashMap<Integer, UnionMain> unionMainByLevelMap = new ConcurrentHashMap<>(); // 联盟主表
    private static ConcurrentHashMap<Integer, UnionBuildMain> unionBuildMainMap = new ConcurrentHashMap<>(); // 联盟建筑主表
    private static ConcurrentHashMap<Integer, UnionBuildUpgrade> unionBuildUpgradeMap = new ConcurrentHashMap<>(); // 建筑升级表
    private static ConcurrentHashMap<Integer, UnionBusiness> unionBusinessMap = new ConcurrentHashMap<>(); // 战备运输中心
    private static ConcurrentHashMap<Integer, UnionDonateMain> unionDonateMainMap = new ConcurrentHashMap<>(); // 联盟每日捐献表
    private static ConcurrentHashMap<Integer, UnionDonateDay> unionDonateDayMap = new ConcurrentHashMap<>(); // 联盟每日捐献成就表
    private static ConcurrentHashMap<Integer, UnionAccumulation> unionAccumulationMap = new ConcurrentHashMap<>(); // 联盟限时充值表
    private static ConcurrentHashMap<Integer, UnionDiscountShop> unionDiscountShopMap = new ConcurrentHashMap<>(); // 联盟砍价商店
    private static ConcurrentHashMap<Integer, UnionBossStage> unionBossStageMap = new ConcurrentHashMap<>(); // 联盟远征boss 表
    private static ConcurrentHashMap<Integer, UnionBoxReward> unionBoxRewardMap = new ConcurrentHashMap<>(); // 联盟宝箱奖励表
    private static ConcurrentHashMap<Integer, UnionDecoration> unionDecorationMap = new ConcurrentHashMap<>(); // 联盟地标装饰表
    private static ConcurrentHashMap<Integer, UnionDecorationEffect> unionDecorationEffectMap = new ConcurrentHashMap<>(); // 联盟地标建筑加成表
    private static CopyOnWriteArrayList<UnionDecorationEffect> unionDecorationEffectList = new CopyOnWriteArrayList<>(); // 联盟地标建筑加成表

    // 公共数据初始化
    public static void init(List<Future> futures) {
        futures.add(initUnionMain());
        futures.add(initUnionDecorate());
        futures.add(initUnionTag());
        futures.add(initUnionBuildMain());
        futures.add(initUnionBuildUpgrade());
        futures.add(initUnionBusiness());
        futures.add(initUnionDonateMain());
        futures.add(initUnionDonateDay());
        futures.add(initUnionAccumulation());
        futures.add(initUnionDiscountShop());
        futures.add(initUnionBossStage());
        futures.add(initUnionBoxReward());
        futures.add(initUnionDecoration());
        futures.add(initUnionDecorationEffect());
    }


    /**
     * 初始化联盟主表
     */
    public static Future<Void> initUnionMain() {
        String table = "union_main";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionMain> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionMain entity = new UnionMain(result.getJsonObject(i));
                        tmp.put(entity.getLevel(), entity);
                    }
                    unionMainByLevelMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionMain getUnionMain(int level) {
        UnionMain result = unionMainByLevelMap.get(level);
        if (result == null) {
            logger.error("getUnionMain error level = " + level);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionMain> getunionMainByLevelMap() { return unionMainByLevelMap; }
    /**
     * 初始化联盟旗帜头像装扮表
     */
    public static Future<Void> initUnionDecorate() {
        String table = "union_decorate";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDecorate> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDecorate entity = new UnionDecorate(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionDecorateMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionDecorate getUnionDecorate(int id) {
        UnionDecorate result = unionDecorateMap.get(id);
        if (result == null) {
            logger.error("getUnionDecorate error key = " + id);
        }
        return result;
    }

    public static List<UnionDecorate> getUnionDecorateList(int type) {
        List <UnionDecorate> list = new ArrayList<>();
        ConcurrentHashMap<Integer, UnionDecorate> map = getUnionDecorateMap();
        for (UnionDecorate entity : map.values()) {
            if (entity.getType() == type) {
                list.add(entity);
            }
        }
        return list;
    }
    public static ConcurrentHashMap<Integer, UnionDecorate> getUnionDecorateMap() { return unionDecorateMap; }


    /**
     * 初始化联盟标签表
     */
    public static Future<Void> initUnionTag() {
        String table = "union_tag";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionTag> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionTag entity = new UnionTag(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionTagMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionTag getUnionTag(int id) {
        UnionTag result = unionTagMap.get(id);
        if (result == null) {
            logger.error("getUnionTag error key = " + id);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionTag> getUnionTagMap() { return unionTagMap; }



    /**
     * 初始化联盟建筑主表
     */
    public static Future<Void> initUnionBuildMain() {
        String table = "union_build_main";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionBuildMain> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionBuildMain entity = new UnionBuildMain(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionBuildMainMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionBuildMain getUnionBuildMain(int id) {
        UnionBuildMain result = unionBuildMainMap.get(id);
        if (result == null) {
            logger.error("getUnionBuildMain error key = " + id);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionBuildMain> getUnionBuildMainMap() { return unionBuildMainMap; }



    /**
     * 初始化建筑升级表
     */
    public static Future<Void> initUnionBuildUpgrade() {
        String table = "union_build_upgrade";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionBuildUpgrade> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionBuildUpgrade entity = new UnionBuildUpgrade(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionBuildUpgradeMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionBuildUpgrade getUnionBuildUpgrade(int id) {
        UnionBuildUpgrade result = unionBuildUpgradeMap.get(id);
        if (result == null) {
            logger.error("getUnionBuildUpgrade error key = " + id);
        }
        return result;
    }

    public static UnionBuildUpgrade getUnionBuildUpgrade(int buildId, int level) {
        UnionBuildUpgrade result = null;
        //System.out.println("builid:" + buildId + " level:" + level);
        for (UnionBuildUpgrade unionBuildUpgrade : unionBuildUpgradeMap.values()) {
            if (unionBuildUpgrade.getBuildId() == buildId && unionBuildUpgrade.getLevel() == level) {
                result = unionBuildUpgrade;
                break;
            }
        }
        return result;
    }

    public static ConcurrentHashMap<Integer, UnionBuildUpgrade> getUnionBuildUpgradeMap() { return unionBuildUpgradeMap; }

    /**
     * 初始化战备运输中心
     */
    public static Future<Void> initUnionBusiness() {
        String table = "union_business";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionBusiness> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionBusiness entity = new UnionBusiness(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionBusinessMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionBusiness getUnionBusiness(int id) {
        UnionBusiness result = unionBusinessMap.get(id);
        if (result == null) {
            logger.error("getUnionBusiness error key = " + id);
        }
        return result;
    }


    public static ConcurrentHashMap<Integer, UnionBusiness> getUnionBusinessMap() { return unionBusinessMap; }


    /**
     * 初始化联盟每日捐献表
     * TODO:key改为type 所以不能直接后台覆盖
     */
    public static Future<Void> initUnionDonateMain() {
        String table = "union_donate_main";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDonateMain> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDonateMain entity = new UnionDonateMain(result.getJsonObject(i));
                        tmp.put(entity.getType(), entity);
                    }
                    unionDonateMainMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionDonateMain getUnionDonateMain(int type) {
        UnionDonateMain result = unionDonateMainMap.get(type);
        if (result == null) {
            logger.error("getUnionDonateMain error type = " + type);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionDonateMain> getUnionDonateMainMap() { return unionDonateMainMap; }


    /**
     * 初始化联盟每日捐献成就表
     */
    public static Future<Void> initUnionDonateDay() {
        String table = "union_donate_day";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDonateDay> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDonateDay entity = new UnionDonateDay(result.getJsonObject(i));
                        tmp.put(entity.getNum(), entity);
                    }
                    unionDonateDayMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionDonateDay getUnionDonateDay(int num) {
        UnionDonateDay result = unionDonateDayMap.get(num);
        if (result == null) {
            logger.error("getUnionDonateDay error num = " + num);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionDonateDay> getUnionDonateDayMap() { return unionDonateDayMap; }

    /**
     * 初始化联盟限时充值表
     */
    public static Future<Void> initUnionAccumulation() {
        String table = "union_accumulation";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionAccumulation> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionAccumulation entity = new UnionAccumulation(result.getJsonObject(i));
                        tmp.put(entity.getNum(), entity);
                    }
                    unionAccumulationMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionAccumulation getUnionAccumulation(int num) {
        UnionAccumulation result = unionAccumulationMap.get(num);
        if (result == null) {
            logger.error("getUnionAccumulation error key num = " + num);
        }
        return result;
    }


    public static ConcurrentHashMap<Integer, UnionAccumulation> getUnionAccumulationMap() { return unionAccumulationMap; }

    /**
     * 初始化联盟砍价商店
     */
    public static Future<Void> initUnionDiscountShop() {
        String table = "union_discount_shop";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDiscountShop> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDiscountShop entity = new UnionDiscountShop(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionDiscountShopMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionDiscountShop getUnionDiscountShop(int id) {
        UnionDiscountShop result = unionDiscountShopMap.get(id);
        if (result == null) {
            logger.error("getUnionDiscountShop error key = " + id);
        }
        return result;
    }

    public static ConcurrentHashMap<Integer, UnionDiscountShop> getUnionDiscountShopMap() { return unionDiscountShopMap; }

    public static List<UnionDiscountShop> getUnionDiscountShopMapList () {
        List<UnionDiscountShop> list = new ArrayList<>();
        for ( UnionDiscountShop unionDiscountShop : unionDiscountShopMap.values()) {
            list.add(unionDiscountShop);
        }
        return list;
    }

    /**
     * 初始化联盟远征boss 表
     */
    public static Future<Void> initUnionBossStage() {
        String table = "union_boss_stage";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionBossStage> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionBossStage entity = new UnionBossStage(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionBossStageMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionBossStage getUnionBossStage(int id) {
        UnionBossStage result = unionBossStageMap.get(id);
        if (result == null) {
            logger.error("getUnionBossStage error key = " + id);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionBossStage> getUnionBossStageMap() { return unionBossStageMap; }

    /**
     * 初始化联盟宝箱奖励表
     */
    public static Future<Void> initUnionBoxReward() {
        String table = "union_box_reward";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionBoxReward> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionBoxReward entity = new UnionBoxReward(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionBoxRewardMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionBoxReward getUnionBoxReward(int id) {
        UnionBoxReward result = unionBoxRewardMap.get(id);
        if (result == null) {
            logger.error("getUnionBoxReward error key = " + id);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionBoxReward> getUnionBoxRewardMap() { return unionBoxRewardMap; }


    /**
     * 初始化联盟地标装饰表
     */
    public static Future<Void> initUnionDecoration() {
        String table = "union_decoration";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDecoration> tmp = new ConcurrentHashMap<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDecoration entity = new UnionDecoration(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                    }
                    unionDecorationMap = tmp;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static UnionDecoration getUnionDecoration(int id) {
        UnionDecoration result = unionDecorationMap.get(id);
        if (result == null) {
            logger.error("getUnionDecoration error key = " + id);
        }
        return result;
    }
    public static ConcurrentHashMap<Integer, UnionDecoration> getUnionDecorationMap() { return unionDecorationMap; }



    /**
     * 初始化联盟地标建筑加成表
     */
    public static Future<Void> initUnionDecorationEffect() {
        String table = "union_decoration_effect";
        Promise promise = Promise.promise();
        String sql = "select * from " + table + ";";
        MysqlTool.queryJsonArrayFromDb(MysqlClient.getCommonPool(), sql, new JsonArray(), res -> {
            if (res.succeeded()) {
                try {
                    ConcurrentHashMap<Integer, UnionDecorationEffect> tmp = new ConcurrentHashMap<>();
                    CopyOnWriteArrayList<UnionDecorationEffect> effectList = new CopyOnWriteArrayList<>();
                    JsonArray result = res.result();
                    logger.info("init " + table + " size:" + result.size());
                    for (int i = 0; i < result.size(); i++) {
                        UnionDecorationEffect entity = new UnionDecorationEffect(result.getJsonObject(i));
                        tmp.put(entity.getId(), entity);
                        effectList.add(entity);
                    }
                    effectList.sort(Comparator.comparingInt(UnionDecorationEffect::getLevel));
                    unionDecorationEffectMap = tmp;
                    unionDecorationEffectList = effectList;
                    promise.complete();
                } catch (Exception e) {
                    logger.error("init " + table + " error exception:" + Tool.getException(e));
                    promise.fail(e);
                }
            } else {
                logger.error(res.cause().getMessage());
                promise.fail(res.cause());
            }
        });
        return promise.future();
    }

    public static CopyOnWriteArrayList<UnionDecorationEffect> getUnionDecorationEffectList() {
        return unionDecorationEffectList;
    }
}
